<?php
// CONFIG GERAL //
if ( defined('ABSPATH') )
	require_once( ABSPATH . 'ov_config.php');
else
    require_once('../ov_config.php'); // tem que ser relativo!

require_once(ABSPATH . LIB . '/gmaps-api/GoogleMap.php');
require_once(ABSPATH . LIB . '/gmaps-api/JSMin.php');

function geraMapa($endereco,$cidade,$estado) {
	if (isset($endereco) && (strlen($endereco) > 5)) {
		$MAP_OBJECT = new GoogleMapAPI();
		$MAP_OBJECT->_minify_js = isset($_REQUEST["min"]) ? FALSE : TRUE;
		$addr = iconv("ISO-8859-1", "UTF-8", urldecode($endereco).", ".$cidade." - ".$estado.", BRA");
		// DIE($addr);
		$tmp = $MAP_OBJECT->geoGetCoordsFull($addr);
		$precision = $tmp->results[0]->geometry->location_type;
		if (isset($precision) && ($precision != "APPROXIMATE")) {
			$MAP_OBJECT->addMarkerByAddress($addr);
			$MAP_OBJECT->setHeight(320);
			$MAP_OBJECT->setWidth(430);
			$MAP_OBJECT->setMapType(ROADMAP);
			return $MAP_OBJECT;
		}
	}
}
?>